﻿using System;
using System.Diagnostics.Contracts;
using System.IO;
using OpenLS.Spreadsheet.Formats.Biff.Records;

namespace OpenLS.Spreadsheet.Formats.Biff.OfficeArt
{
    internal class OfficeArtClientData : OfficeArtRecord
    {
        private ObjRecord objRecord;

        public OfficeArtClientData(Comment comment, OfficeArtWriteContext context)
        {
            Contract.Assert(comment.Text != null);
            this.objRecord = context.CreateObjRecord(comment);

        }


        public OfficeArtClientData()
        {
        }

        public override RecType RecordType
        {
            get { return RecType.OfficeArtClientData; }
        }

        

        protected override void ReadNoHeader(OfficeArtReadContext context)
        {
            Contract.Assert(rhrecVer == 0x00);
            Contract.Assert(rhrecInstance == 0x0);
            Contract.Assert(rhrecType == (RecType) 0xF011);
            Contract.Assert(rhrecLen == 0);
        }
        protected override void PostReadNoHeader(OfficeArtReadContext context)
        {
            this.objRecord = context.GetObjRecord((int)context.BaseStream.Position);
            if (objRecord != null)
                objRecord.OfficeArtClientData = this;
            else
            {
              //\\  Contract.Assert(false);
            }

        }

        protected override byte Version
        {
            get { return 0; }
        }

        protected override int ByteLength
        {
            get { return 0; }
        }


        protected override void WriteNoHeader(OfficeArtWriteContext context)
        {
            Contract.Assert(rhrecVer == 0x00);
            Contract.Assert(rhrecInstance == 0x0);
            Contract.Assert(rhrecType == (RecType)0xF011);
            Contract.Assert(rhrecLen == 0);
            if (objRecord != null)
            {
                context.AddEmbeddedObjRecord(this.objRecord);
            }

        }

        protected override void PrepareHeader(ref OfficeArtRecordHeader rh)
        {
        }
    }
}